url = '/account/orders.html'
description = '用户订单历史'
layout = 'default'

[session]
security = "user"
redirect = "account/login"
==
use Jason\Ccshop\Controllers\Orders;
function onStart() {
    $this['orderStatus'] = (new Orders())->myOrdersStatus();
    $orderStatus = (new Orders())->myOrdersStatus();
    $cr = 0;
    $op = 0;

    foreach($orderStatus as $os){
        if($os['status_id'] == 6){
           $cr += $os['count'];
        }
        if($os['status_id'] == 8){
          $cr += $os['count'];
        }
        if($os['status_id'] == 1){
          $op += $os['count'];
        }
        if($os['status_id'] == 9){
          $op += $os['count'];
        }
    }
  $this['cr']=$cr;
  $this['op']=$op;

  $xxkkcc =App::make('Jason\Ccshop\Components\Catalog')->orders();
  //dd($xxkkcc[0]['products']);
}
==

{% put page_title %}ご注文履歴 - {% default %}{% endput %}
{% set orders = catalog.orders %}
{% set Addresses = catalog.getAddresses %}

<div class="orderCont pd_b3">
	<section style="margin-top: 35px;">
		<div class="_tabArea">		
			<div class="flatTab_contents">
				<div class="_contents _selected">
					{% if count(orders) > 0 %}
					<table class="">
						<tr>
							<td width="30%">商品情報</td>
							<td>金額</td>
							<td>数量</td>
							<td>合計金額</td>
							<td>注文状况</td>
						</tr>
						{% for key, order in orders %}
						{% if order.order_status.code == 'placed' or order.order_status.code == 'pressed' %}
						<tr>
							<th colspan="5">
								<b>注文NO.：</b>{{ order.sn }}
								<br />
								<b>ご注文日付と時間：</b>{{ formatDate("m/d/Y H:i:s", order.created_at) }}
							</th>
						</tr>
						{% for m, orderproduct in order.products %}
						{% set condition = { 'id': orderproduct.product_id } %}
						{% set product = catalog.product(condition) %}
						<tr style="height: 50px;">
							<td width="30%">
							<div class="orderdiv">
								<a class="table_type_a" href="{{product.url}}" title="{{ orderproduct.name }}" target="_blank">
									<img title="{{ orderproduct.name }}" src="{{ product.getMainThumb(150,150) }}">
								</a>
								<p style="clear: both;width: 85px;margin-bottom: 5px;" class="text-overflow">
									<a href="{{product.url}}" target="_blank">{{ orderproduct.name }}</a>
								</p>
								{#{ form_open({'request': 'onRePaymentOrder', 'class': 'checkoutForm','id':'yy_onRePaymentOrder_'~order.sn}) }#}
								<input type="hidden" name="key" value="{{ order.sn }}">
								<!--<button type="submit" form="yy_onRePaymentOrder_{{order.sn}}">今すぐ支払う</button>-->
								{#{ form_close() }#}
								<a href="/repay-{{ order.sn }}-{{ order.payment_method }}-p.html" class="pay_btn">今すぐ支払う</a>
								<p><button><a class="orderXx" href="/orderdetail-{{ order.sn }}.html">詳細</a></button></p>
							</div>									
												
							</td>
							<td class="shop_price">
								{{ orderproduct.price|formatPriceNotRate }}								
							</td>
							<td class="num">
								× {{ orderproduct.qty }}								
							</td>
							<td class="subtotal" >
								{{ order.total_price|formatPriceNotRate }}
							</td>
							<td class="subtotal" >	
								{{ ('jason.ccshop::lang.order.status.' ~ order.order_status.code)|trans }}						
							</td>
						</tr>
				
						{% endfor %}
						{% endif %}
						{% endfor %}

					</table>
					{% else %}											
					<h4 style="text-align:center;margin-top:20px;color:#615757;">ご注文いただいた履歴はございません。</h4>
					{% endif %}
				</div>
			</div>
		</div>
	</section>
</div>

